//
//  YesmaiModel.swift
//
//  Created by eme on 2016/12/25
//  Copyright (c) . All rights reserved.
//

import Foundation
import SwiftyJSON
import ModelProtocol

class YesmaiModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kYesmaiSkuidKey: String = "skuid"
    internal let kYesmaiPdidKey: String = "pdid"
    internal let kYesmaiEditnumKey: String = "editnum"
    
    
    // MARK: 属性
    var skuid: Int
    var pdid: Int
    var editnum: Int
    var pdcode:String
    var psvalue:String
    
    
    
    // MARK: 实现ModelProtocol 协议， 解析json数据
    required  init?(json: JSON) {
        skuid = json[kYesmaiSkuidKey].intValue
        pdid = json[kYesmaiPdidKey].intValue
        editnum = json[kYesmaiEditnumKey].intValue
        pdcode = json["pdcode"].stringValue
        psvalue = json["psvalue"].stringValue
        
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    internal func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        
        dictionary.updateValue(skuid as AnyObject, forKey: kYesmaiSkuidKey)
        
        dictionary.updateValue(pdid as AnyObject, forKey: kYesmaiPdidKey)
        
        dictionary.updateValue(editnum as AnyObject, forKey: kYesmaiEditnumKey)
        
        dictionary.updateValue(pdcode as AnyObject, forKey: "pdcode")
        
        dictionary.updateValue(psvalue as AnyObject, forKey: "psvalue")
        
        return dictionary
    }
    
    
}
